import Layout from '@/views/layout/Layout';

// 控制这系列页面的权限
const authData = {
  energy: ['energy:energyList:read'], // 精力分配
  target: ['crm:target:read'], // 双微目标
  signTarget: ['crm:signTarget:read'], // 签约目标
  publish: ['publish:publishList:read'], // 发布管理
  accounts: ['crm:accounts:read'], // 账号监测
  hotList: ['crm:hotList:read'] // 实时热榜
};
let pageAllAuth = [];
for (const key in authData) {
  pageAllAuth = pageAllAuth.concat(authData[key]);
}

// 首页
const OperateRouter = [{
  path: '/operate',
  component: Layout,
  redirect: '/operate/energy',
  name: 'operate',
  meta: { title: '运营', icon: 'sidebar-operate', authControl: pageAllAuth },
  children: [{
    path: 'energy',
    name: 'energy',
    meta: { title: '精力分配', keepAlive: true, isChange: false, headerBarShow: false, authControl: authData.energy },
    component: () => import('@/views/energy/index')
  }, {
    path: 'publish',
    name: 'publish',
    meta: { title: '发布管理', keepAlive: true, isChange: false, headerBarShow: false, authControl: authData.publish },
    component: () => import('@/views/publish/index')
  }, {
    path: 'accounts',
    name: 'accounts',
    meta: { title: '账号监测', keepAlive: false, isChange: false, headerBarShow: false, authControl: authData.accounts },
    component: () => import('@/views/accounts/index')
  }, {
    path: 'target',
    name: 'target',
    parentName: '目标管理',
    meta: { title: '双微目标', keepAlive: false, isChange: false, authControl: authData.target, hideHeaderBarTitle: true, headerBarShow: true, activeMenu: '/operate/target' },
    component: () => import('@/views/target/index')
  }, {
    path: 'signTarget',
    name: 'signTarget',
    parentName: '目标管理',
    meta: { title: '签约目标', keepAlive: false, isChange: false, authControl: authData.signTarget, hideHeaderBarTitle: true, headerBarShow: true, activeMenu: '/operate/signTarget' },
    component: () => import('@/views/signTarget/index')
  },
  // {
  //   path: 'hotList',
  //   name: 'hotList',
  //   component: () => import('@/views/hotIndex/index'),
  //   meta: { title: '实时热榜', keepAlive: false, isChange: true, headerBarShow: true, authControl: authData.hotList }
  // },
  /**
   * 内页
   **/
  {
    path: 'energy/create',
    name: 'energyCreate',
    hidden: true,
    component: () => import('@/views/energy/create/index'),
    meta: { title: '新建精力分配', headerBarShow: true, activeMenu: '/operate/energy' } // headerBarShow 为true显示头像
  }, {
    path: 'energy/edit',
    name: 'energyEdit',
    hidden: true,
    component: () => import('@/views/energy/create/index'),
    meta: { title: '编辑精力分配', headerBarShow: true, activeMenu: '/operate/energy' } // headerBarShow 为true显示头像
  }, {
    path: 'energy/detail',
    name: 'energyDetail',
    hidden: true,
    component: () => import('@/views/energy/detail/index'),
    meta: { title: '精力分配详情', headerBarShow: true, activeMenu: '/operate/energy' }
  }, {
    path: 'energy/detail/edit',
    name: 'energyDetailEdit',
    hidden: true,
    component: () => import('@/views/energy/detail/edit'),
    meta: { title: '精力分配编辑', headerBarShow: true, activeMenu: '/operate/energy' }
  }, {
    path: 'target/edit',
    name: 'targetEdit',
    hidden: true,
    meta: { title: '编辑双微目标', hideHeaderBarTitle: true, headerBarShow: true, authControl: authData.target, activeMenu: '/operate/target' },
    component: () => import('@/views/target/edit')
  }, {
    path: 'signTarget/edit',
    name: 'signTargetEdit',
    hidden: true,
    meta: { title: '编辑签约目标', hideHeaderBarTitle: true, headerBarShow: true, authControl: authData.signTarget, activeMenu: '/operate/signTarget' },
    component: () => import('@/views/signTarget/edit')
  }, {
    path: 'accounts/detail/:id',
    name: 'accountsDetail',
    hidden: true,
    component: () => import('@/views/accounts/detail/accountsDetail'),
    meta: { title: '账号详情', headerBarShow: true, activeMenu: '/operate/accounts' }
  }, {
    path: 'publish/detail/:id',
    name: 'publishDetail',
    hidden: true,
    component: () => import('@/views/publish/detail/index'),
    meta: { title: '资源报告', headerBarShow: true, activeMenu: '/operate/publish' }
  }]
}];

export default OperateRouter;
